package top.linyuxb.lycloud.rpc.starter.config;

import cn.hutool.extra.spring.EnableSpringUtil;
import jakarta.annotation.Resource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import top.linyuxb.lycloud.rpc.starter.common.LyRpcBeanUtil;
import top.linyuxb.lycloud.rpc.starter.controller.LyRpcServerController;
import top.linyuxb.lycloud.rpc.starter.properties.LyRpcServerProperties;

import java.util.Map;

/**
 * Created by Intellij IDEA.
 *
 * @Author: linyuxb
 * @Date: 2024/5/31 16:51
 * @Desc:
 */
@Configuration
@EnableConfigurationProperties(LyRpcServerProperties.class)
@EnableSpringUtil
@Import(LyRpcServerController.class)
@ConditionalOnProperty(
        prefix = "ly-rpc-server",
        name = "open",
        havingValue = "true"
)
public class LyRpcServerConfig {
    @Resource
    private LyRpcServerProperties lyRpcServerProperties;

    @Bean(name = "lyRpcServerClassMap")
    public Map<String, Class<?>> serverClassMap() {
        return LyRpcBeanUtil.getServerClassMap(lyRpcServerProperties);
    }

}
